<?php
// +----------------------------------------------------------------------
// | KITEGO-Admin「开箱即用」「人人全栈」
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.kitego.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed KITEGO并不是自由软件，未经许可不能去掉KITEGO相关版权
// +----------------------------------------------------------------------
// | Author: KITEGO Team <bd@kitego.cn>
// +----------------------------------------------------------------------

namespace app\adminapi\listener;

use app\dao\setting\SystemMenuDao;
use kitego\services\common\CacheService;

class UpdateAdminAuthListener
{
    public function handle($event)
    {
        if ((isset($event) && $event == 1) || env('app_debug')) {
            CacheService::set('allAuthListQuery', app()->make(SystemMenuDao::class)->getColumn([['auth', '<>', '']], 'id, is_verify, method, auth'));
        }

        return CacheService::remember('allAuthListQuery', function () {
            return app()->make(SystemMenuDao::class)->getColumn([['auth', '<>', '']], 'id, is_verify, method, auth');
        });
    }
}
